package com.feng.web;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class showImage extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String name = request.getParameter("n");
		
		BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File("C:/upload",name)));
		OutputStream out = response.getOutputStream();
		
		byte[] buffer = new byte[512];
		int len = -1;
		while((len = bis.read(buffer)) != -1) {
			out.write(buffer, 0, len);
		}
		
		out.flush();
		out.close();
	}

}
